package com.shop.coupon.controller;

import com.shop.common.core.domain.PageResult;
import com.shop.common.core.domain.Result;
import com.shop.coupon.domain.Coupon;
import com.shop.coupon.service.CouponService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/coupon")
public class CouponController {
    private final CouponService couponService;

    public CouponController(CouponService couponService) {
        this.couponService = couponService;
    }

    @GetMapping("/couponShow")
    public Result<PageResult<Coupon>> couponShow(@RequestParam Integer pageNum ,  Integer pageSize){
        return couponService.couponShow(pageNum,pageSize);
    }

    @PostMapping("/couponInsert")
    public Result<Coupon> couponInsert(@RequestBody Coupon coupon){
        return couponService.couponInsert(coupon);
    }

    @PostMapping("/couponUpdate")
    public Result<Coupon> couponUpdate(@RequestBody Coupon coupon){
        return couponService.couponUpdate(coupon);
    }

    @GetMapping("/couponDelete")
    public Result<Coupon> couponDelete(@RequestParam Long id){
        return couponService.couponDelete(id);
    }

    @GetMapping("/getCoupon")
    public Result<Coupon> getCoupon(@RequestParam Long id){
        return couponService.getCoupon(id);
    }

    @GetMapping("/couponUpdPublish")
    public Result<Coupon> couponUpdPublish(@RequestParam Long id){
        return couponService.couponUpdPublish(id);
    }

    @GetMapping("/couponUpdStop")
    public Result<Coupon> couponUpdStop(@RequestParam Long id){
        return couponService.couponUpdStop(id);
    }

    @GetMapping("/getSelectCoupon")
    public Result<Coupon> getSelectCoupon(){
        return couponService.getSelectCoupon();
    }
}
